<template>
  <div :class="$style.layout">
    <div :class="$style.header" v-if="showHeader">
      <div :class="$style.goBack" @click="back">
        <img src="~/static/images/Rectangle.png" alt>
        返回
      </div>
      <div :class="$style.title">{{data["title"]}}</div>
      <div :class="[$style.menu,showNav && $style.active]" @click="showMenu">菜单</div>
    </div>
    <div :class="$style.content">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    showHeader: {
      type: Boolean,
      default: true
    },
    showNav: Boolean,
    data: Object
  },
  methods: {
    showMenu() {
      this.$emit("update:showNav", !this.showNav);
    },
    back() {
      top.window.location.back();
    }
  }
};
</script>

<style lang="less" module>
.layout {
  display: flex;
  position: relative;
  .header {
    position: fixed;
    top: 0;
    width: 100%;
    height: 88px;
    line-height: 88px;
    background: #ffae34;
    padding: 0 35px 0 24px;
    box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.33);
    font-size: 32px;
    color: #333;
    display: flex;
    justify-items: center;
    z-index: 10;
    .title {
      flex: 1;
      text-align: center;
      font-size: 36px;
    }
    .goBack {
      width: 100px;
      > img {
        width: 20px;
        height: 34px;
        vertical-align: middle;
        margin-top: -6px;
      }
    }
    .menu {
      width: 100px;
      text-align: right;
      &.active {
        color: #f70002;
      }
    }
  }
  .content {
    flex: 1;
  }
}
</style>
